package org.jeecg.modules.veterans.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.system.entity.SysUserCountSta;
import org.jeecg.modules.system.vo.SysNameValueVo;
import org.jeecg.modules.veterans.entity.SysService;
import org.jeecg.modules.veterans.entity.SysServiceApp;
import org.jeecg.modules.veterans.entity.SysServiceDiscount;
import org.jeecg.modules.veterans.entity.SysServicePriority;
import org.jeecg.modules.veterans.mapper.SysServiceAppMapper;
import org.jeecg.modules.veterans.mapper.SysServiceMapper;
import org.jeecg.modules.veterans.service.ISysServiceAppService;
import org.jeecg.modules.veterans.service.ISysServiceDiscountService;
import org.jeecg.modules.veterans.service.ISysServicePriorityService;
import org.jeecg.modules.veterans.service.ISysServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 优待服务信息表
 * @Author: jeecg-boot
 * @Date:   2022-04-06
 * @Version: V1.0
 */
@Service
public class SysServiceAppServiceImpl extends ServiceImpl<SysServiceAppMapper, SysServiceApp> implements ISysServiceAppService {

    @Resource
    private SysServiceAppMapper sysServiceAppMapper;
    @Autowired
    private ISysServiceDiscountService discountService;
    @Autowired
    private ISysServicePriorityService priorityService;

    @Override
    public Page<SysServiceApp> queryDiscountListByCircle(Page<SysServiceApp> page, double lng, double lat, String distance,String area,String type,String sort,String searchCon){
        String[] areas = StringUtils.split(area,",");
        if (page.getSize() == -1) {
            return page.setRecords(sysServiceAppMapper.queryDiscountListByCircle(lng,lat,distance,areas,type,sort,searchCon,page.getCurrent(),page.getSize()));
        } else {
            return page.setRecords(sysServiceAppMapper.queryDiscountListByCircle(lng,lat,distance,areas,type,sort,searchCon,page.getCurrent(),page.getSize()));
        }
    }

    @Override
    public Page<SysServiceApp> queryServiceListByCircle(Page<SysServiceApp> page, double lng, double lat, String distance,String area,String sort,String serviceType){
        String[] areas = StringUtils.split(area,",");
        if (page.getSize() == -1) {
            return page.setRecords(sysServiceAppMapper.queryServiceListByCircle(lng,lat,distance,areas,sort,serviceType,page.getCurrent(),page.getSize()));
        } else {
            return page.setRecords(sysServiceAppMapper.queryServiceListByCircle(lng,lat,distance,areas,sort,serviceType,page.getCurrent(),page.getSize()));
        }
    }

    @Override
    public List<SysServiceApp> selectList(QueryWrapper queryWrapper){
        return sysServiceAppMapper.selectList(queryWrapper);
    }

    @Override
    public Integer queryServiceMountByArea(int area){
        return sysServiceAppMapper.queryServiceMountByArea(area);
    }

    @Override
    public Integer queryServiceMountByAreaAndServiceType(int area,String serviceType){
        return sysServiceAppMapper.queryServiceMountByAreaAndServiceType(area,serviceType);
    }



}
